import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'

const req = require.context('./modules', false, /\.js$/)
console.log(req)
const ModulesName = req.keys().map(item => item.split('./')[1]).map(item => item.split('.js')[0])
console.log(ModulesName)
const Modules = req.keys().map(req)
console.log(Modules)
const obj = {}

ModulesName.forEach((ele, index) => {
  obj[ele] = Modules[index].default
})
console.log(obj)
Vue.use(Vuex)

const store = new Vuex.Store({
  modules: obj,
  getters
})

export default store
